import { fileURLToPath, URL } from 'node:url'

import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'

// https://vitejs.dev/config/
export default defineConfig({
  base: "./",
  plugins: [
    vue(),
  ],
  resolve: {
    alias: {
      "@": fileURLToPath(new URL("./src", import.meta.url)),
    },
  },
  css: {
    preprocessorOptions: {
      scss: {
        // 修改api调用方式
        // 解决控制台出现Deprecation Warning: The legacy JS API is deprecated and will be removed in Dart Sass 2.0.0的问题
        api: "modern-compiler", 
        // 导出全局变量和 mixin， sass 1.80 全局变量和 mixin 需要手动导出到全局
        // 参考 https://sass-lang.com/documentation/at-rules/use
        // additionalData的作用在每个scss文件编译的过程中自动添加额外的scss代码到每个文件头部
        additionalData: `@use "@/assets/style/global.scss" as *;`, 
      },
    },
  },
});
